package com.you.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.alibaba.citrus.util.FileUtil;

public class MixTool {

    public static String format(Date date, String format) {
        if (date == null) {
            return "";
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        return simpleDateFormat.format(date);
    }

    public static String shortFileName(String name) {
        FileUtil.FileNameAndExtension fileNameAndExtension = FileUtil.getFileNameAndExtension(name);
        String photoName = fileNameAndExtension.getFileName();
        if (photoName.length() > 5) {
            photoName = photoName.substring(0, 5);
        }
        return photoName + "." + fileNameAndExtension.getExtension();
    }

    public static void main(String[] args) {

        System.out.println(MixTool.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    }
}
